function show_add() {
//store
	var formStore = new Ext.data.Store( [ 'bianma_zeng', 'mingcheng_zeng',
			'fenlei_zeng_hidden', 'hanyi_zeng', 'miaoshu_zeng', 'jingdu_zeng',
			'danwei_zeng', 'bumen_zeng', 'laiyuan_zeng', 'koujing_zeng',
			'zhouqi_zeng', 'zhibiaozhi_zeng', 'juhe_zeng', 'keyong_zeng' ]);

	
	
//fenlei begin
	var nodeid;
	var selectedNode = null;
	var comb_fenlei = new Ext.form.ComboBox(
			{
				id : 'fenlei_zeng',
				store : new Ext.data.SimpleStore( {
					fields : [],
					data : [ [] ]
				}),
				editable : false,
				fieldLabel : '所属分类',
				shadow : false,
				mode : 'local',
				emptyText : '请选择所属分类',
				anchor : '70%',
				triggerAction : 'all',
				tpl : '<tpl for="."><div style="height:200px"><div id="tree_fenlei"></div></div></tpl>',
				selectedClass : '',
				onSelect : Ext.emptyFn
			});
	
	var tree_root = new Ext.tree.AsyncTreeNode( {
		text : '指标分类',
		id : 0000
	});

	var tree = new Ext.tree.TreePanel(
			{
				border : '0',
				height : 200,
				useArrows : true,
				autoScroll : true,
				animate : true,
				enableDD : false,
				containerScroll : true,
				rootVisible : false,
				root : tree_root,
				autoScroll : true,
				lines : false,
				iconCls : 'nav',
				checkModel : 'cascade',
				onlyLeafCheckable : false,
				titleCollapse : true,
				listeners : {
					beforeload : function(node) {
						var openUrl = basePath + 'JarpListener?className=cn.com.jsepc.rep.catalog.CatalogDAO&methodName=getCatalog&paramCount=0'
						node.loader = new Ext.tree.TreeLoader( {
							dataUrl : openUrl
						});
					}
				}
			});

	tree.on('click', function(node) {
		selectedNode = node;
		var nodename = node.text;
		Ext.ComponentMgr.get("fenlei_zeng").setValue(nodename);
	    Ext.ComponentMgr.get("fenlei_zeng_hidden").setValue(node.id);		
		selectedNode = null;
		comb_fenlei.canCollapse = true; 
		comb_fenlei.collapse();
	});

	comb_fenlei.on('expand', function() {
		tree.render('tree_fenlei');
	});
	
	tree.on('expandnode', function() { comb_fenlei.canCollapse = true; });
	tree.on('beforeload', function() { comb_fenlei.canCollapse = false; });
	tree.on('beforeexpandnode', function() { comb_fenlei.canCollapse = false; });
	tree.on('beforecollapsenode', function() { comb_fenlei.canCollapse = false; });

	comb_fenlei.on('expand', function () {
		comb_fenlei.canCollapse = true;
            if (tree) {
            	comb_fenlei.canCollapse = true;          
            	tree.getRootNode().expand();
                
            }
      });
	comb_fenlei.on('collapse', function() {
            if (!comb_fenlei.canCollapse) {
            	comb_fenlei.expand();
            }
        });	
//fenlei end
	
	
//dept begin
	var selectedNode_dept = null;
	var comb_dept = new Ext.form.ComboBox(
			{
				id : 'dept_zeng',
				store : new Ext.data.SimpleStore( {
					fields : [],
					data : [ [] ]
				}),
				editable : false,
				fieldLabel : '归口部门',
				shadow : false,
				mode : 'local',
				emptyText : '请选择归口部门',
				anchor : '70%',
				triggerAction : 'all',
				tpl : '<tpl for="."><div style="height:200px"><div id="tree_dept"></div></div></tpl>',
				selectedClass : '',
				onSelect : Ext.emptyFn
			});
	
	var tree_root_dept = new Ext.tree.AsyncTreeNode( {
		text : '部门',
		id : -1
	});

	var tree_dept = new Ext.tree.TreePanel(
			{
				border : '0',
				height : 200,
				useArrows : true,
				autoScroll : true,
				animate : true,
				enableDD : false,
				containerScroll : true,
				rootVisible : false,
				root : tree_root_dept,
				autoScroll : true,
				lines : false,
				iconCls : 'nav',
				checkModel : 'cascade',
				onlyLeafCheckable : false,
				titleCollapse : true,
				listeners : {
					beforeload : function(node) {
						var openUrl = basePath + 'JarpListener?className=cn.com.jsepc.rep.report.CorpDeptTree&methodName=getCorpDeptTreeData&paramCount=2';
						openUrl += '&param_0='+node.id+'&param_1=';
						node.loader = new Ext.tree.TreeLoader( {
							dataUrl : openUrl
						});
					}
				}
			});

	tree_dept.on('click', function(node) {
		selectedNode_dept = node;
		nodeid = node.id;
		var nodename = node.text;
		Ext.ComponentMgr.get("dept_zeng").setValue(nodename);
	    Ext.ComponentMgr.get("bumen_zeng").setValue(nodeid);		
		//comb_dept.collapse();注释掉
		selectedNode_dept = null;
		comb_dept.canCollapse = true; //add
        comb_dept.collapse(); //add
	});

	comb_dept.on('expand', function() {
		tree_dept.render('tree_dept'); 
	});
//	tree_dept.on('expandnode', function(node) {
//		comb_dept.expand();     注释
//	});
	
	//以下事件，让combobox能正常关闭 add
	tree_dept.on('expandnode', function() { comb_dept.canCollapse = true; });
	tree_dept.on('beforeload', function() { comb_dept.canCollapse = false; });
	tree_dept.on('beforeexpandnode', function() { comb_dept.canCollapse = false; });
	tree_dept.on('beforecollapsenode', function() { comb_dept.canCollapse = false; });

    comb_dept.on('expand', function () {
    	comb_dept.canCollapse = true;
            if (tree_dept) {
            	comb_dept.canCollapse = true;          
            	tree_dept.getRootNode().expand();
                
            }
      });
    comb_dept.on('collapse', function() {
            if (!comb_dept.canCollapse) {
            	comb_dept.expand();
            }
        });	
	
//	dept  end
	
//*******************主窗口****************************//	
	  var win_add = new Ext.Window( {
			title : '指标信息维护',
			layout : 'fit',
			width : 420,
			height : 480,
			closeAction : 'close',
			plain : true,
			modal:true,
			layout : "border",
			tbar : ['-', {
				text : "保存",
				handler : function() {
					saveForm();
				}
			},'-', {
				text : "关闭",
				handler : function() {
				    win_add.close();
				}
			},'-' ],

			items : new Ext.FormPanel( {
				labelWidth : 100,
				labelAlign : "left",
				layout : "form",
				region : "center",
				frame : true,
				items : [
						{
							xtype : "textfield",
							xtype : 'hidden',
							fieldLabel : "指标编号",
							emptyText : '保存成功后自动生成',
							allowBlank : false,
							disabled : true,
							id : 'bianhao_zeng',
							anchor : "70%"
						},
						{
							xtype : "textfield",
							fieldLabel : "指标编码",
							allowBlank : false,
							id : 'bianma_zeng',
							anchor : "70%",
							emptyText : '字母或下划线开头',
							regex :/^[A-Za-z_]+[A-Za-z0-9_]*$/
						},
						{
							xtype : "textfield",
							fieldLabel : "指标名称",
							emptyText : '请填写',
							blankText : '此项必填',
							allowBlank : false,
							anchor : "70%",
							id : 'mingcheng_zeng'
						},
						[ comb_fenlei ],
						{
							xtype : "hidden",
							fieldLabel : "所属分类",
							anchor : "70%",
							id : 'fenlei_zeng_hidden'
						},
						{
							xtype : "textarea",
							fieldLabel : "指标含义(最多可填350汉字)",
							emptyText : '选填',
							anchor : "85%",
							id : 'hanyi_zeng'
						},
						{
							xtype : "textarea",
							fieldLabel : "算法描述(最多可填500汉字)",
							emptyText : '选填',
							anchor : "85%",
							id : 'miaoshu_zeng'
						},
						{
							xtype : "numberfield",
							fieldLabel : "数据精度",
							allowBlank : false,
							emptyText : '请填写数字(不超过9)',
							blankText : '此项必选',
							anchor : "70%",
							id : 'jingdu_zeng',
							regex : /^[0-9]$/
						},
						{
							xtype : "textfield",
							fieldLabel : "数据单位",
							emptyText : '可填写任意字符',
							blankText : '如：人,个',
							allowBlank : false,
							anchor : "70%",
							id : 'danwei_zeng'
						},
						[ comb_dept ],
						{
							xtype : "hidden",
							fieldLabel : "归口部门",
							emptyText : '可填写任意字符(必填)',
							blankText : '必填选项',
							allowBlank : false,
							anchor : "70%",
							id : 'bumen_zeng'
						},
						new Ext.form.ComboBox( {
							fieldLabel : "数据来源类型",
							anchor : "70%",
							emptyText : '请选择数据来源类型(必选项)',
							blankText : '此项必选',
							id : 'laiyuan_zeng',
							editable : false,
							triggerAction : 'all',
							store : [ [ '1', '自动抽取' ], [ '2', '手工填报' ] ],
							mode : 'remote',
							valueField : 'value',
							displayField : 'text'
						}),{
							xtype:'hidden',
							id : 'koujing_zeng',
							value:'0'
						},
						/*new Ext.form.ComboBox( {
							fieldLabel : "数据口径",
							anchor : "65%",
							emptyText : '请选择数据口径(必选项)',
							blankText : '此项必选',
							id : 'koujing_zeng',
							editable : false,
							triggerAction : 'all',
							store : [ [ '1', '全口径' ], [ '2', '国网' ],
									[ '3', '省网' ], [ '4', '上报国网' ],
									[ '5', '统调口径' ] ],
							mode : 'remote',
							valueField : 'value',
							displayField : 'text'
						})*/
						new Ext.form.ComboBox( {
							fieldLabel : "更新周期",
							anchor : "70%",
							emptyText : '请选择数据周期(必选项)',
							blankText : '此项必选',
							id : 'zhouqi_zeng',
							editable : false,
							triggerAction : 'all',
							store : [ [ '1', '年' ], [ '2', '季' ], [ '3', '月' ],
									[ '4', '日' ], [ '5', '时' ], [ '6', '分' ] ],
							mode : 'remote',
							valueField : 'value',
							displayField : 'text'
						}), {
							xtype : "hidden",
							fieldLabel : "关联事实表",
							anchor : "70%",
							disabled : true,
							id : 'shishibiao_zeng'
						}, {
							xtype : "hidden",
							fieldLabel : "指标值字段",
							anchor : "70%",
							disabled : false,
							id : 'zhibiaozhi_zeng',
							emptyText : '字母或下划线开头',
							blankText : '此项必填',
							regex : /^[A-Za-z_]+[A-Za-z0-9_]*$/
						}, new Ext.form.ComboBox( {
							fieldLabel : "是否聚合",
							anchor : "70%",
							emptyText : '请选择(必选项)',
							blankText : '此项必选',
							id : 'juhe_zeng',
							editable : false,
							triggerAction : 'all',
							store : [ [ '1', '可聚合' ], [ '0', '不可聚合' ] ],
							mode : 'remote',
							valueField : 'value',
							displayField : 'text'
						}), new Ext.form.ComboBox( {
							fieldLabel : "是否可用",
							anchor : "70%",
							emptyText : '请选择(必选项)',
							blankText : '此项必选',
							id : 'keyong_zeng',
							editable : false,
							triggerAction : 'all',
							store : [ [ '1', '可用' ], [ '0', '不可用' ] ],
							mode : 'remote',
							valueField : 'value',
							displayField : 'text'
						}) ]
			})
		})
	win_add.show(this);
//=================================================================//	  
	
	Ext.ComponentMgr.get("jingdu_zeng").setValue("0");//排除浏览器失把0当成空的情况
	
	//获取指标分类的值
    Ext.ComponentMgr.get("fenlei_zeng").setValue(Ext.getCmp("getnode_name").getValue());
	Ext.ComponentMgr.get("fenlei_zeng_hidden").setValue(Ext.getCmp("getnode_id").getValue());

	function saveForm() {
		//获取值存入store，准备传入后台
		formStore.bianma_zeng = Ext.ComponentMgr.get("bianma_zeng").getValue();
		formStore.mingcheng_zeng = Ext.ComponentMgr.get("mingcheng_zeng").getValue();
		formStore.fenlei_zeng_hidden = Ext.getCmp("fenlei_zeng_hidden").getValue();
		formStore.hanyi_zeng = Ext.ComponentMgr.get("hanyi_zeng").getValue();
		formStore.miaoshu_zeng = Ext.ComponentMgr.get("miaoshu_zeng").getValue();
		formStore.jingdu_zeng = Ext.ComponentMgr.get("jingdu_zeng").getValue();
		formStore.danwei_zeng = Ext.ComponentMgr.get("danwei_zeng").getValue();
		formStore.bumen_zeng = Ext.ComponentMgr.get("bumen_zeng").getValue();
		formStore.laiyuan_zeng = Ext.ComponentMgr.get("laiyuan_zeng").getValue();
	//	formStore.koujing_zeng = Ext.ComponentMgr.get("koujing_zeng").getValue();
		formStore.koujing_zeng = 0;
		formStore.zhouqi_zeng = Ext.ComponentMgr.get("zhouqi_zeng").getValue();
		formStore.zhibiaozhi_zeng = Ext.ComponentMgr.get("zhibiaozhi_zeng").getValue();
		formStore.juhe_zeng = Ext.ComponentMgr.get("juhe_zeng").getValue();
		formStore.keyong_zeng = Ext.ComponentMgr.get("keyong_zeng").getValue();
		
		//待传入的url地址		
		var saveItemInfoUrl = "";
		saveItemInfoUrl = '?className=cn.com.jsepc.rep.report.zhibiao_manage';
		saveItemInfoUrl += '&methodName=addzhibiao';
		saveItemInfoUrl += '&paramCount=0';
		saveItemInfoUrl = basePath + 'JarpListener' + saveItemInfoUrl;

		//文本框验证
		if (formStore.bianma_zeng == null || formStore.bianma_zeng == "") {
			Ext.Msg.alert('提示', '指标编码不能为空！');
		} else if (isDigit(formStore.bianma_zeng)) {
			Ext.Msg.alert('提示', '指标编码只能为大写字母、数字和下划线格式，并且只能以字母和下划线开头！');
		} else if (formStore.mingcheng_zeng == null
				|| formStore.mingcheng_zeng == "") {
			Ext.Msg.alert('提示', '指标名称不能为空！');
		} else if (formStore.fenlei_zeng_hidden == null || formStore.fenlei_zeng_hidden == "") {
			Ext.Msg.alert('提示', '指标分类不能为空！');
		} else if ((formStore.hanyi_zeng).length > 350) {
			Ext.Msg.alert('提示', '指标含义不能超过350个汉字');
		} else if ((formStore.miaoshu_zeng).length > 500) {
			Ext.Msg.alert('提示', '指标描述不能超过500个汉字');
		} else if (formStore.jingdu_zeng != 0 && formStore.jingdu_zeng == "") {
			Ext.Msg.alert('提示', '指标精度不能为空');
		} else if (formStore.jingdu_zeng > 9) {
			Ext.Msg.alert('提示', '指标精度为正整数0-9！');
		} else if (formStore.danwei_zeng == null || formStore.danwei_zeng == "") {
			Ext.Msg.alert('提示', '数据单位不能为空！');
		} else if (formStore.bumen_zeng == null || formStore.bumen_zeng == "") {
			Ext.Msg.alert('提示', '归口部门不能为空！');
		} else if (formStore.laiyuan_zeng == null
				|| formStore.laiyuan_zeng == "") {
			Ext.Msg.alert('提示', '数据来源不能为空！');
		}
//		else if (formStore.koujing_zeng == null
//				|| formStore.koujing_zeng == "") {
//			Ext.Msg.alert('提示', '口径类型必选！');
//		} 
		else if (formStore.zhouqi_zeng == null || formStore.zhouqi_zeng == "") {
			Ext.Msg.alert('提示', '周期必选！');
		} 
//		else if (formStore.zhibiaozhi_zeng == null
//				|| formStore.zhibiaozhi_zeng == "") {
//			Ext.Msg.alert('提示', '指标值字段必填！');
//		} else if (isDigit(formStore.zhibiaozhi_zeng)) {
//			Ext.Msg.alert('提示', '指标值只能为大写字母、数字和下划线格式，并且只能以字母和下划线开头！');
//		}
		else if (formStore.juhe_zeng == null || formStore.juhe_zeng == "") {
			Ext.Msg.alert('提示', '是否聚合必选！');
		} else if (formStore.keyong_zeng == null || formStore.keyong_zeng == "") {
			Ext.Msg.alert('提示', '是否可用必选！');
		} else {
			//全部符合的情况下：传值
			httpR_itemInfo = getXMLHttpRequest();
			httpR_itemInfo.onreadystatechange = returnItemSave;
			httpR_itemInfo.open("POST", saveItemInfoUrl, true);
			httpR_itemInfo.send(Ext.util.JSON.encode(formStore));
		}
	}
	
	// 判断输入为大写字母和下划线
	function isDigit(s) {
		var patrn = /^[A-Za-z_]+[A-Za-z0-9_]*$/;
		if (patrn.exec(s)) return false
		return true
	}
	
	//判断输入为0-9的正整数
	 function isnumber(s)
	 {
	 var patrn=/^[0-9]$/;
	 if (patrn.exec(s)) return false
	 return true
	 }

	 //返回值 处理
	function returnItemSave() {
		if (httpR_itemInfo.readyState == 4) {
			if (httpR_itemInfo.status == 200) {
				ret = httpR_itemInfo.responseText;
				if (ret == 'haven') {
					Ext.MessageBox.show( {
						title : '提 示',
						msg : ' 数据库已存在此编码 ，请重新填写'
					});
				} else if (ret == 'haven1') {
					Ext.MessageBox.show( {
						title : '提 示',
						msg : ' 数据库已存在此名称 ，请重新填写'
					});
				} else if (ret == 'ok') {
					win_add.close();
					Ext.Msg.alert('提示', '添加成功！');
					var grid_ = Ext.ComponentMgr.get("ggg");
					grid_.store.reload();
				} else {
					Ext.MessageBox.show( {
						title : '提 示',
						msg : ' 未知错误，添加失败 ，请重新填写'
					});
					setTimeout("window.location.reload()", 1500);
				}
			}
		}
	}
}